package com.fz.action;

import com.opensymphony.xwork2.ActionSupport;
import lombok.Data;
import org.apache.struts2.ServletActionContext;

import java.io.FileInputStream;
import java.io.InputStream;

/**
 * Created by Z-C-Y on 2018-02-27.
 * 文件进行下载
 *
 */
@Data
public class Download extends ActionSupport {
    private String fn;
    private String ext;
    private String path;
    public String execute(){
        return "success";
    }

    public InputStream getInputStream() throws Exception {
        String ip = ServletActionContext.getServletContext().getRealPath(path)+"/"+fn+ext;
        InputStream is = new FileInputStream(ip);
        return is;

    }

}
